home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / onlineco / files / ImageMagick-6.0.1-Q16-windows-dll.exe / {app} / ImageMagickObject / Tests / SimpleTest.vbs < prev   
Encoding:
Text File  |  2003-04-03  |  1.5 KB  |  52 lines

  1. Option Explicit
  2.  
  3. On Error Resume Next
  4. Const ERROR_SUCCESS = 0
  5.  
  6. Dim img
  7. Dim info
  8. Dim msgs
  9. Dim elem
  10. Dim sMsgs
  11.  
  12. '
  13. ' This is the simplest sample I could come up with. It creates
  14. ' the ImageMagick COM object and then sends a copy of the IM
  15. ' logo out to a JPEG image files on disk.
  16. '
  17. Set img = CreateObject("ImageMagickObject.MagickImage.1")
  18. '
  19. ' The methods for the IM COM object are identical to utility
  20. ' command line utilities. You have convert, composite, identify,
  21. ' mogrify, and montage. We did not bother with animate, and
  22. ' display since they have no purpose in this context.
  23. '
  24. ' The argument list is exactly the same as the utility programs
  25. ' as a list of strings. In fact you should just be able to
  26. ' copy and past - do simple editing and it will work. See the
  27. ' other samples for more elaborate command sequences and the
  28. ' documentation for the utility programs for more details.
  29. '
  30. msgs = img.Convert("logo:","-format","%m,%h,%w","logo.jpg")
  31. '
  32. ' By default - the string returned is the height, width, and the
  33. ' type of the image that was output. You can control this using
  34. ' the -format "xxxxxx" command as documented by identify.
  35. '
  36. If Err.Number <> ERROR_SUCCESS Then ShowError: WScript.Quit
  37. MsgBox "info: " & msgs
  38. Set img=Nothing
  39. WScript.Quit(0)
  40.  
  41. Sub ShowError
  42.   sMsgs = ""
  43.   If BasicError(Err.Number) > 5000 Then
  44.     sMsgs = " ImageMagickObject" & vbCrLf
  45.   End If
  46.   WScript.Echo Err.Number & ": " & Err.Description & vbCrLf & sMsgs
  47. End Sub
  48.  
  49. Function BasicError(e)
  50.   BasicError = e And &HFFFF&
  51. End Function
  52.